﻿using System;
using System.Threading;

namespace Bettzueche_CCR.Benchmarks {

    class Program {
        /// <summary>
        /// Führt je 10 mal CCR-, CCR_APM- und PortSet-Test aus.
        /// Die Ergebnisse werden in einer Logdatei festgehalten.
        /// </summary>
        /// <param name="args">Anzahl Schleifendurchläufen (per default 1000)</param>
        static void Main(string[] args) {

            int schleifen = 1000;
            int posts;
            APM apm;
            CCR_APM ccrApm;
            PortSetTest psTest;

            if (args != null && args.Length >= 1) {
                if (!int.TryParse(args[0], out schleifen))
                    schleifen = 1000;
            }
            if (schleifen < 10000) {
                Console.WriteLine(" Note: for PortSet-Test, Repitions scaled up to 10,000");
                posts = 10000;
            }
            else
                posts = schleifen;

            for (int i = 0; i < 10; i++) {
                apm = new APM(schleifen);
                apm.Start();
                apm = null;
                Thread.Sleep(2000);
                ccrApm = new CCR_APM(schleifen);
                ccrApm.Start();
                ccrApm = null;
                Thread.Sleep(2000);
                psTest = new PortSetTest(posts);
                psTest.LogFile = "PortSet_Benchmark.log";
                psTest.Start();
                Thread.Sleep(2000);
            }
            Console.Write("Press any key to quit");
            Console.ReadKey(true);
        }
    }
}
